﻿Public Class Form2
    Dim valor_ingreso As String
    Dim costo As Double
    Dim total_acumulado As Double = 0
    Dim total_descripcion As String = ""
    Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        If Form1.user.Trim = "Empleado" And Form1.pass.Trim = "123456" Then
            InhabilitarMenu2()
        End If
    End Sub
    Sub InhabilitarMenu2()
        Me.ProcesosPropiToolStripMenuItem.Visible = False
    End Sub

    Private Sub AgregarEntradaToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AgregarEntradaToolStripMenuItem.Click
        valor_ingreso = InputBox("Ingrese el nueva entrada")
        If valor_ingreso.Trim <> "" Then
            ListBox1.Items.Add(valor_ingreso)
        End If

    End Sub

    Private Sub EliminarEntradaToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EliminarEntradaToolStripMenuItem.Click
        ListBox1.Items.Remove(ListBox1.SelectedItem)
    End Sub

    Private Sub AgregarSegundoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AgregarSegundoToolStripMenuItem.Click
        valor_ingreso = InputBox("Ingrese el nuevo segundo")
        If valor_ingreso.Trim <> "" Then
            ListBox2.Items.Add(valor_ingreso)
        End If

    End Sub

    Private Sub EliminarSegundoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EliminarSegundoToolStripMenuItem.Click
        ListBox2.Items.Remove(ListBox2.SelectedItem)
    End Sub

    Private Sub AgregarPostreToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AgregarPostreToolStripMenuItem.Click
        valor_ingreso = InputBox("Ingrese el nuevo postre")
        If valor_ingreso.Trim <> "" Then
            ListBox3.Items.Add(valor_ingreso)
        End If

    End Sub

    Private Sub EliminarPostreToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EliminarPostreToolStripMenuItem.Click
        ListBox3.Items.Remove(ListBox3.SelectedItem)
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Try
            Form3.Visible = True
            Call Form3.Parametros(ListBox1.SelectedItem.ToString, ListBox2.SelectedItem.ToString, ListBox3.SelectedItem.ToString, ComboBox1.SelectedItem.ToString, ComboBox2.SelectedItem.ToString, (Numerico.Value * costo).ToString)
            total_acumulado = total_acumulado + costo * Numerico.Value
            total_descripcion = total_descripcion + ComboBox1.SelectedItem + "  " + (Numerico.Value * costo).ToString & Global.Microsoft.VisualBasic.ChrW(10)
        Catch ex As Exception
            MsgBox("Rellene datos antes de enviar", MsgBoxStyle.Critical, "Error de usuario")
            Form3.Visible = False
        End Try
    End Sub

    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        If ComboBox1.SelectedItem.ToString = "Economico" Then
            costo = 4.5
        ElseIf ComboBox1.SelectedItem.ToString = "Normal" Then
            costo = 6
        ElseIf ComboBox1.SelectedItem.ToString = "Ejecutivo" Then
            costo = 7.5
        Else
            costo = 9
        End If
        TextBox1.Text = costo * Numerico.Value
    End Sub

    Private Sub GenerarPropiosToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GenerarPropiosToolStripMenuItem.Click
        If total_acumulado <> 0 Then
            Form4.Visible = True
            Call Form4.Datos(total_descripcion, total_acumulado)
        Else
            MsgBox("Llene al menos un procedimiento", MsgBoxStyle.Exclamation, "Error de inicio de operaciones")
        End If
        
    End Sub

    Private Sub Numerico_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Numerico.ValueChanged
        TextBox1.Text = costo * Numerico.Value
    End Sub

    Private Sub SalirToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SalirToolStripMenuItem.Click
        Me.Dispose()
        Form1.Show()
    End Sub

    Private Sub AcercaDeToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AcercaDeToolStripMenuItem.Click
        Form5.Show()
    End Sub
End Class